//购物车接口
import type { CartItem } from '@/types/cart'
import { http } from '@/utils/http'

//获取购物车列表
export const getCartListAPI = () => {
  return http<CartItem[]>({
    method: 'GET',
    url: '/member/cart',
  })
}
//加入购物车
export const postAddCartAPI = (data: { skuId: string; count: number }) => {
  http({
    method: 'POST',
    url: '/member/cart',
    data,
  })
}
//修改购物车单品
export const putUpdateCartAPI = (data: { skuId: string; count?: number; selected?: boolean }) => {
  http({
    method: 'PUT',
    url: `/member/cart/${data.skuId}`,
    data,
  })
}
//购物车全选取消全选
export const putSelectAllAPI = (data: { selected: boolean }) => {
  http({
    method: 'PUT',
    url: '/member/cart/selected',
    data,
  })
}
